import {defineAsyncComponent} from 'vue'
/**
 * 定义组件数据类型
 */
export interface ComItem {
    name: TableTypes,
    component: any
}

/**
 * 自定义自己拥有的组件
 */
export const SelfComs = [
    {
        name: 'input',
        component: defineAsyncComponent(() => import('./components/input.vue')),
    },
    {
        name: 'autocomplete',
        component: defineAsyncComponent(() => import('./components/autocomplete.vue')),
    },
    {
        name: 'checkbox',
        component: defineAsyncComponent(() => import('./components/checkbox.vue')),
    },
    {
        name: 'inputNumber',
        component: defineAsyncComponent(() => import('./components/inputNumber.vue')),
    },
    {
        name: 'switch',
        component: defineAsyncComponent(() => import('./components/switch.vue')),
    },
    {
        name: 'timePicker',
        component: defineAsyncComponent(() => import('./components/timePicker.vue')),
    },
    {
        name: 'timeSelect',
        component: defineAsyncComponent(() => import('./components/timeSelect.vue')),
    },
    {
        name: 'rate',
        component: defineAsyncComponent(() => import('./components/rate.vue')),
    },
    {
        name: 'slider',
        component: defineAsyncComponent(() => import('./components/slider.vue')),
    },
    {
        name: 'select',
        component: defineAsyncComponent(() => import('./components/select.vue')),
    },
    {
        name: 'treeSelect',
        component: defineAsyncComponent(() => import('./components/treeSelect.vue')),
    },
    {
        name: 'datePicker',
        component: defineAsyncComponent(() => import('./components/datePicker.vue')),
    },
    {
        name: 'colorPicker',
        component: defineAsyncComponent(() => import('./components/colorPicker.vue')),
    },
    {
        name: 'slot',
        component: defineAsyncComponent(() => import('./components/Slot.vue')),
    },
] as const;

export type TableTypes = (typeof SelfComs)[number]["name"] |
  string;

/**
 * 定义额外补充的组件
 */
export const otherComs: ComItem[] = []


export function getComponents() {
    let result = {}
    SelfComs.forEach(a => {
        result['DynamicTable' + a.name] = a.component
    })
    otherComs.forEach(a => {
        result['DynamicTable' + a.name] = a.component
    })
    return result
}
